home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / user / manofthematch.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  5KB  |  201 lines

  1. /* Mode=Run */
  2. /* ***********************************************************************
  3.  
  4.    MAN OF THE MATCH PROGRAM FOR FOOTBALL REXX SUITE
  5.   --------------------------------------------------
  6.                    Copyright  Mark Naughton 1999
  7.  
  8.  
  9. Version    Date     History
  10. --------------------------------------------------------------------------
  11.  1.0       170699   First release.
  12.            250899   Added error msg to file check.
  13.            280899   Converted to use locale. Some error messages, before
  14.                     reading the locale, will still be in English.
  15.            141099   Added team name to player.
  16.  
  17. **************************************************************************
  18.  
  19. Procedure
  20. ---------
  21.  
  22. 1. Check file exists.
  23. 2. Open '.sflearn' file and read in players, storing them and if the name
  24.    appears more than once, increment the number of awards per match.
  25. 3. Write players out to temp file and sort.
  26. 4. Display table.
  27. 5. Read temp file and display players with total merits. Exit.
  28.  
  29. ************************************************************************** */
  30. PARSE ARG league_stuff
  31.  
  32. version      = 1
  33. input_file   = '.sflearn'
  34. homemm       = '*HM='
  35. awaymm       = '*AM='
  36. mmnm         = '**'
  37. separator    = '*'
  38. teams.       = '???'
  39. wins.        = '???'
  40. lines.       = '???'
  41. counter      = 0
  42.  
  43.  
  44. league_file = "Data/" || league_stuff
  45.  
  46.  
  47. if open(datafile,"Data/Football.locale",'r') then do
  48.    line = readln(datafile)
  49.    locdir = strip(line)
  50.    close(datafile)
  51. end
  52. else do
  53.    say
  54.    say "ERROR :    (ManOfTheMatch)"
  55.    say
  56.    say "Cannot read 'Data/Football.locale' for the locale settings."
  57.    exit
  58. end
  59.  
  60. locdir = locdir"User/ManOfTheMatch.data"
  61.  
  62. if open(datafile,"ENV:FootballRXPath",'r') then do
  63.    line = readln(datafile)
  64.    rxdir = strip(line)
  65.    close(datafile)
  66. end
  67. else
  68.    rxdir = "SYS:Rexxc/"
  69.  
  70. if exists(locdir) > 0 then do
  71.   address command rxdir'rx 'locdir
  72.   VarCount = getclip('VarCount')
  73.   do i = 1 to VarCount
  74.     interpret getclip('var.'i)
  75.   end
  76. end
  77. else do
  78.    say
  79.    say "ERROR :    (ManOfTheMatch)"
  80.    say
  81.    say "Cannot find '"locdir"' to read locale settings."
  82.    exit
  83. end
  84.  
  85. if exists(league_file || input_file) = 0  then do
  86.    say
  87.    say mm_error
  88.    say
  89.    say mm_one"'"league_file || input_file"'."
  90.    exit
  91. end
  92.  
  93. if open(datafile,league_file || input_file,'r') then do
  94.    do while ~eof(datafile)
  95.       line = readln(datafile)
  96.       if pos(mmnm,line) > 0 then
  97.          lname = delstr(line,1,3)
  98.       if pos(separator,line) = 0 then
  99.          match_plyd = line
  100.       if pos(homemm,line) > 0 then do
  101.          name = delstr(line,1,4)
  102.          notin = 0
  103.          do i=1 to counter
  104.             if pos(name,teams.i) > 0 then do
  105.                wins.i = wins.i + 1
  106.                notin = 1
  107.             end
  108.          end
  109.          if notin = 0 then do
  110.             counter = counter + 1
  111.             teams.counter = name" ("strip(substr(match_plyd,1,30))")"
  112.             wins.counter  = 1
  113.          end
  114.       end
  115.       if pos(awaymm,line) > 0 then do
  116.          name = delstr(line,1,4)
  117.          notin = 0
  118.          do i=1 to counter
  119.             if pos(name,teams.i) > 0 then do
  120.                wins.i = wins.i + 1
  121.                notin = 1
  122.             end
  123.          end
  124.          if notin = 0 then do
  125.             counter = counter + 1
  126.             teams.counter = name" ("strip(substr(match_plyd,41,30))")"
  127.             wins.counter  = 1
  128.          end
  129.       end
  130.    end
  131.    close(datafile)
  132. end
  133. else do
  134.    say
  135.    say mm_error
  136.    say
  137.    say mm_two"'"league_file||input_file"'"mm_three
  138.    exit
  139. end
  140.  
  141. if counter > 1 then do
  142.    if open(datafile,"RAM:Football.tempcup",'w') then do
  143.       do i=1 to counter
  144.          writeln(datafile,left(wins.i,4)"     "teams.i)
  145.       end
  146.       close(datafile)
  147.    end
  148.    else do
  149.       say
  150.       say mm_error
  151.       say
  152.       say mm_four
  153.       exit
  154.    end
  155.    address command 'Exec/Sort4Chars '
  156. end
  157.  
  158.  
  159. say
  160. say center(mm_txt1"'"lname"'",78)
  161. say "-------------------------------------------------------------------------------"
  162. say
  163. say
  164. say mm_txt2
  165. say "-------------------------------------------------------------------------------"
  166. say
  167. i = 0
  168. if counter = 1 then do
  169.    say right("1)",4," ")"   "left(wins.1,4)"     "upper(teams.1)
  170.    say
  171. end
  172. else do
  173.    ll = 1
  174.    if open(datafile,"RAM:Football.tempcup",'r') then do
  175.       do while ~eof(datafile)
  176.          line = readln(datafile)
  177.          if line~="" then do
  178.             if i = 0 then do
  179.                say right(ll")",4," ")"   "upper(line)
  180.                i = 1
  181.             end
  182.             else
  183.                say right(ll")",4," ")"   "line
  184.             ll = ll + 1
  185.          end
  186.       end
  187.       close(datafile)
  188.    end
  189.    else do
  190.       say
  191.       say mm_error
  192.       say
  193.       say mm_txt3
  194.       exit
  195.    end
  196.    address command 'delete >NIL: RAM:Football.tempcup'
  197. end
  198. say
  199. say "-------------------------------------------------------------------------------"
  200.  
  201. exit